import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";
import Layout from "@/layouts/index.vue";

export const constantRoutes: RouteRecordRaw[] = [
    {
        path: "/redirect",
        component: Layout,
        meta: { hidden: true },
        children: [
            {
                path: "/redirect/:path(.*)",
                component: () => import("@/views/redirect/index.vue"),
            },
        ],
    },
    {
        path: "/login",
        name: "登录",
        component: () => import("@/views/login/index.vue"),
        meta: {
            hidden: true,
        },
    },
    {
        path: "/:pathMatch(.*)*",
        component: () => import("@/views/error/404.vue"),
        meta: {
            hidden: true,
        },
    },
    {
        path: "",
        component: Layout,
        redirect: "/index",
        children: [
            {
                path: "/index",
                component: () => import("@/views/home/index.vue"),
                name: "Index",
                meta: { title: "指示版", icon: "dashboard", affix: true },
            },
        ],
    },
];

const router = createRouter({
    // HTML5 模式路由
    history: createWebHistory(),
    routes: constantRoutes,
});

export default router;
